using System.Collections.Generic;
using System.Text;

namespace Behaviorize.CodeGenerator.CodeModel
{
	public class Feature
	{
		public Feature()
		{
			Scenarios = new List<Scenario>();
		}

		public string Name { get; internal set; }
		public Story Story { get; internal set; }
		public IList<Scenario> Scenarios { get; internal set; }
		public string Description { get; internal set; }

		public override string ToString()
		{
			var spec = new StringBuilder();
			spec.AppendFormat("Feature: {0}\n\n", Name);

			if (!string.IsNullOrEmpty(Description)) spec.AppendFormat("{0}\n\n", Description);

			if (Story != null)
			{
				spec.AppendFormat("As a {0}\n", Story.Role);
				spec.AppendFormat("I want {0}\n", Story.Goal);
				spec.AppendFormat("so that {0}\n\n", Story.Motivation);
			}

			foreach (Scenario scenario in Scenarios)
			{
				spec.Append(scenario);
				spec.AppendLine("");
			}

			return spec.ToString().Trim();
		}
	}
}